package cn.jzq.kotoba.modules.designpattern.strategy.charge.demo;

import cn.jzq.kotoba.modules.designpattern.strategy.charge.ChargeTypeEnum;

import java.util.HashMap;
import java.util.Map;

public class StrategyFactory {
 
    private static StrategyFactory factory = new StrategyFactory();
    private StrategyFactory(){
    }
    private static Map<Integer, Strategy> strategyMap = new HashMap<>();

    static{
       strategyMap.put(ChargeTypeEnum.E_BANK.getType(), new EBankStrategy());
       strategyMap.put(ChargeTypeEnum.USER_ACCOUNT.getType(), new UserAccountStrategy());
       strategyMap.put(ChargeTypeEnum.MOBILE.getType(), new MobileStrategy());
       strategyMap.put(ChargeTypeEnum.CARD_CHARGE.getType(), new CardStrategy());
    }
    public Strategy creator(Integer type){
       return strategyMap.get(type);
    }
    public static StrategyFactory getInstance(){
       return factory;
    }
} 